//
//  Team9s_respondCell.m
//  Team9Project
//
//  Created by dlios on 15/10/16.
//  Copyright © 2015年 apple. All rights reserved.
//

#import "Team9s_respondCell.h"
#import "Team9s_respondModel.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation Team9s_respondCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatAllView];
    }
    return self;
}




    
- (void)setRespondModel:(Team9s_respondModel *)respondModel{
    if (_respondModel != respondModel) {
        _respondModel = respondModel;
    }

    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:_respondModel.author_face] placeholderImage:[UIImage imageNamed:@"333"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        [UIView animateWithDuration:0.3 animations:^{
            CATransition *transition = [CATransition animation];
            transition.type = @"fade";
            [transition setDuration:0.5];
            [transition setRepeatCount:1];
            // 向imageView上添加动画效果
            [self.headImageView.layer addAnimation:transition forKey:@"transition"];
        }];
    }];
    [Team9Tool imageView:self.headImageView type:_respondModel.author_type Id:_respondModel.author_id viewController:self.vc];
    
    self.userLabel.text = _respondModel.author_nick;
    self.contentLabel.text = _respondModel.content;
    self.timeLabel.text = _respondModel.create_time_info;
    
   
    
    
}
    


    

    


-(void)creatAllView
{
    
    
    
    // 头像
    self.headImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.headImageView];
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = 20 / 375.0 * WIDTH ;
    
    // 用户名
    self.userLabel = [[Team9BaseLabel alloc] initWith:LableColorTypeOrangeGreen];
    self.userLabel.font = [UIFont systemFontOfSize:15 / 375.0 * WIDTH];
    [self.contentView addSubview:self.userLabel];

 
    
   
    // 内容
    self.contentLabel = [[Team9BaseLabel alloc] init];
    [self.contentView addSubview:self.contentLabel];
    self.contentLabel.numberOfLines = 0;
    [self.contentLabel sizeToFit];
    self.contentLabel.font = [UIFont systemFontOfSize:13 / 375.0 * WIDTH];
    
    
    self.timeLabel = [[Team9BaseLabel alloc] init];
    [self.contentView addSubview:self.timeLabel];
    self.timeLabel.font = [UIFont systemFontOfSize:13 / 375.0 * WIDTH];
    
    [self creat_Constraints];
    
   
}

- (void)creat_Constraints{

    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10 / 375.0 * WIDTH);
        make.top.equalTo(self.contentView.mas_top).offset(10 / 375.0 * WIDTH);
        make.width.mas_equalTo(40 / 375.0 * WIDTH);
        make.height.mas_equalTo(self.headImageView.mas_width);
    
    }];
    
    [self.userLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.headImageView.mas_right).offset(10 / 375.0 * WIDTH);
        make.top.equalTo(self.contentView.mas_top).offset(20 / 375.0 * WIDTH);
        make.width.mas_equalTo(200 / 375.0 * WIDTH);
        make.height.mas_equalTo(20 / 375.0 * WIDTH);
        
    }];
    
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headImageView.mas_bottom).offset(10 / 375.0 * WIDTH);
        make.left.equalTo(self.headImageView.mas_left);
        make.width.mas_equalTo(WIDTH - 20 / 375.0 * WIDTH);
        
    }];
    
    
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(10 / 375.0 * WIDTH);
        make.top.equalTo(self.contentLabel.mas_bottom).offset(15 / 375.0 * WIDTH);
        make.width.mas_equalTo(100 / 375.0 * WIDTH);
        make.height.mas_equalTo(15 / 375.0 * WIDTH);
        
        
    }];

    
    

}





-(void)layoutSubviews
{
    [super layoutSubviews];
    
}
    
    
    




@end
